<template>
  <section>
    <!--工具条-->
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
      <el-form :inline="true" :model="searchForm">
        <el-form-item>
          <el-input v-model="searchForm.keyword" placeholder="寻主消息名称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getSearchMasterMsgs">查询</el-button>
        </el-form-item>
      </el-form>
    </el-col>

    <!--列表-->
    <el-table :data="searchMasterMsgs" highlight-current-row v-loading="listLoading" style="width: 100%;">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column type="index" width="60">
      </el-table-column>
      <el-table-column prop="name" label="名称" >
      </el-table-column>
      <el-table-column prop="title" label="标题" >
      </el-table-column>
      <el-table-column prop="price" label="价格" >
      </el-table-column>
      <el-table-column prop="age" label="年龄"  >
      </el-table-column>
      <el-table-column prop="gender" label="性别"  >
        <template scope="scope" >
          <span v-if="scope.row.gender==0" style="color: red">母</span>
          <span v-if="scope.row.gender!=0" style="color: green">公</span>
        </template>
      </el-table-column>
      <el-table-column prop="coat_color" label="毛色"  >
      </el-table-column>
      <el-table-column prop="address" label="地址"  >
      </el-table-column>
      <el-table-column prop="type.name" label="品种"  >
      </el-table-column>
      <el-table-column prop="user.username" label="用户"  >
      </el-table-column>
      <el-table-column prop="shop.name" label="店铺"  >
      </el-table-column>
    </el-table>

    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange"
                     :page-size="pageSize" :total="totals" :current-page="currentPage" style="float:right;">
      </el-pagination>
    </el-col>
  </section>
</template>

<script>

export default {
  data() {
    return {
      fileList:[],
      searchForm: {
        keyword: null
      },
      searchMasterMsgs: [],
      //分页查询 - 总数量
      totals: 0,
      //分页查询 - 当前页
      pageSize: 5,
      //分页查询 - 每页显示的条数
      currentPage: 1,
      listLoading: false,
    }
  },
  methods: {
    //点击某一页的处理
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getSearchMasterMsgs();
    },
    //高级查询 + 分页查询
    getSearchMasterMsgs() {
      let para = {
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        keyword:this.searchForm.keyword
      };
      //打开加载的效果
      this.listLoading = true;
      //
      this.$http.post("/searchMasterMsg/processed",para).then(res=>{
        this.searchMasterMsgs=res.data.rows;
        this.totals=res.data.total;
        //关闭加载的效果
        this.listLoading = false;
      });
    }
  },
  mounted() {
    //当页面加载完以后。执行的方法
    this.getSearchMasterMsgs();
  }
}

</script>

<style scoped>

</style>